#include<bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int T,n,m,L,V;
int d[MAX],v[MAX],a[MAX],p[MAX],spe_cnt;
struct cam_plus{
    int l,r;
};
bool cmp(cam_plus a,cam_plus b){
    if(a.l==b.l)return a.r<b.r;
    return a.l<b.l;
}
vector<cam_plus> Cams;
vector<cam_plus> saves;
void search_cam(int car_id,double l,double r){
    if(l>r)return;
    //printf("%f %f ",l,r);
    int l1 = 1,l2 = m,p1,p2;
    while(l1<l2){
        int mid = (l1+l2)>>1;
        if(p[mid]<l){
            l1 = mid+1;
        }
        else l2 = mid;
    }
    while(l1-1>=1 && p[l1-1]>=l)l1--;
    while(p[l1]<l && l1+1<=m)l1++;
    while(l1-1>=1 && p[l1-1]>=l)l1--;
    //printf("%d ",l1);
    p1 = l1;
    l1 = 1,l2 = m;
    while(l1<l2){
        int mid = (l1+l2)>>1;
        if(p[mid]>r){
            l2 = mid;
        }
        else l1 = mid+1;
    }
    while(p[l1]>r)l1--;
    while(l1+1<=m && p[l1+1]<=r)l1++;
    p2 = l1;
    //printf("%d\n",p2);
    if(p1<=p2){
        spe_cnt++;
    }
    else return;
    bool flag = 0;
    saves.push_back((cam_plus){p1,p2});
}
void check(){
    sort(saves.begin(),saves.end(),cmp);
    for(int j=0;j<saves.size();j++){
        bool flag = 0;
        int p1 = saves[j].l;
        int p2 = saves[j].r;
        for(int i=0;i<Cams.size();i++){
            if(p2>=Cams[i].l&&p2<=Cams[i].r || p1<=Cams[i].r&&p1>=Cams[i].l || Cams[i].l>=p1&&Cams[i].l<=p2 ||Cams[i].r>=p1 && Cams[i].l<=p2){//we can combine them
                Cams[i].l = max(Cams[i].l,p1);
                Cams[i].r = min(Cams[i].r,p2);
                flag = 1;
                continue;
            }
        }
        if(!flag){
            Cams.push_back(saves[j]);
        }
/*
        printf("%d\n",Cams.size());
        for(int i=0;i<Cams.size();i++){
            printf("%d %d\n",Cams[i].l,Cams[i].r);
        }*/
    }
}
void test_car(int x){
    if(v[x]>V){
        if(a[x]>=0){
            search_cam(x,1.0*d[x],1.0*L);
        }
        else{
            double dis = 1.0*(V*V-v[x]*v[x])/(2.0*a[x]);
            double pos = 1.0*d[x]+dis-0.0001;
            search_cam(x,1.0*d[x],min(pos,L*1.0));
       }
    }
    else{
        if(a[x]>0){
            double dis = 1.0*(V*V-v[x]*v[x])/(2.0*a[x]);
            double pos = 1.0*d[x]+dis+0.0001;
            search_cam(x,pos,L*1.0);
        }
    }
}
void Init(){
    spe_cnt = 0;
    Cams.clear();
    saves.clear();
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        Init();
        scanf("%d %d %d %d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d %d %d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        sort(p+1,p+1+m);
        for(int i=1;i<=n;i++)test_car(i);
        check();
        printf("%d %d\n",spe_cnt,m-Cams.size());
        //printf("\n");
    }
    return 0;
}
